import React from 'react';
import { ErrorBoundary, MenuBar } from '@/components';
import { useLocation } from 'umi';
import { StoreProvider } from 'think-react-store';
import * as stores from '@/stores';

const layout: React.FC<any> = (props: any) => {
  const location = useLocation();
  const paths = ['/', '/order', '/user'];
  return (
    <StoreProvider store={stores}>
      <MenuBar
        show={paths.includes(location.pathname)}
        pathName={location.pathname}
      />
      <ErrorBoundary>{props.children}</ErrorBoundary>
    </StoreProvider>
  );
};

export default layout;
